(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseHousekeepingServUser: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseHousekeepingServUserInfo: {
                housekeepingServUsers: [],
                _currentHousekeepingServUserName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseHousekeepingServUser', 'openChooseHousekeepingServUserModel', function (_param) {
                $('#chooseHousekeepingServUserModel').modal('show');
                $that._refreshChooseHousekeepingServUserInfo();
                $that._loadAllHousekeepingServUserInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllHousekeepingServUserInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        communityId: vc.getCurrentCommunity().communityId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('housekeepingServUser.listHousekeepingServUsers',
                    param,
                    function (json) {
                        var _housekeepingServUserInfo = JSON.parse(json);
                        $that.chooseHousekeepingServUserInfo.housekeepingServUsers = _housekeepingServUserInfo.housekeepingServUsers;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseHousekeepingServUser: function (_housekeepingServUser) {
                if (_housekeepingServUser.hasOwnProperty('name')) {
                    _housekeepingServUser.housekeepingServUserName = _housekeepingServUser.name;
                }
                vc.emit($props.emitChooseHousekeepingServUser, 'chooseHousekeepingServUser', _housekeepingServUser);
                vc.emit($props.emitLoadData, 'listHousekeepingServUserData', {
                    housekeepingServUserId: _housekeepingServUser.housekeepingServUserId
                });
                $('#chooseHousekeepingServUserModel').modal('hide');
            },
            queryHousekeepingServUsers: function () {
                $that._loadAllHousekeepingServUserInfo(1, 10, $that.chooseHousekeepingServUserInfo._currentHousekeepingServUserName);
            },
            _refreshChooseHousekeepingServUserInfo: function () {
                $that.chooseHousekeepingServUserInfo._currentHousekeepingServUserName = "";
            }
        }

    });
})(window.vc);
